SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.[DnnProduct_GetRolesBasicSearch]
(
	@PortalID int,					-- portal
	@PageSize int,					-- page size
	@FilterBy nvarchar(100)			-- filter field
)
AS
BEGIN
	SELECT TOP (@PageSize) 
	RoleID,PortalID,RoleName,Description,ServiceFee,BillingFrequency,TrialPeriod,TrialFrequency,BillingPeriod,TrialFee,IsPublic,AutoAssignment,RoleGroupID,RSVPCode,CASE WHEN LEFT(LOWER(IconFile), 7) = 'fileid=' THEN
			(SELECT Folder + FileName
				FROM dbo.[DnnProduct_Files]
				WHERE fileid = CAST((RIGHT(LOWER(IconFile), Len(IconFile) - 7)) AS int)
			) ELSE ''
			END AS IconFile,
			CreatedByUserID,CreatedOnDate,LastModifiedByUserID,LastModifiedOnDate, Status, SecurityMode
	FROM dbo.[DnnProduct_Roles]
	WHERE RoleName LIKE '%' + @FilterBy + '%'
	AND (PortalID = @PortalID OR (@PortalID is null))
	ORDER BY RoleName
END
GO
